package CutLoad.components
{
	import CutLoad.Base;
	import CutLoad.transitions.cloud.SpringPopup;

	/**
	 * 带有弹出效果的弹出 管理
	 * @author smallerbird mail:smallerbird@gmail.com  site:www.mkigm.com QQ群:49983196
	 * 
	 */
	public class CPopupSpring extends CPopup
	{
		private var topPP:SpringPopup=null;
		private var arrPP:Array;
		public function CPopupSpring()
		{
			arrPP=new Array();
		}
		override public function popup(base:Base, t:Number=0, bakColor:Number=0xffffff, bakAlpha:Number=0.5, xx:Number=0, yy:Number=0):Number{
			var index:Number=super.popup(base,t,bakColor,bakAlpha,xx,yy);
			SpringPopupOne(base);
			return index;
		}
		protected function SpringPopupOne(base:Base):void{
			var pp:SpringPopup=new SpringPopup(base);
			topPP=pp;
			arrPP.push({b:base,pp:pp});
		}
		override public function popupNoBak(base:Base, t:Number=0, xx:Number=0, yy:Number=0):Number{
			var index:Number=super.popupNoBak(base,t,xx,yy)
			SpringPopupOne(base);
			return index;
		}
		override public function removeTop():void{
			if(arrPP.length==0) return; 
			if(topPP!=null){
				topPP.ReverseStart();
				arrPP.pop();
				super.removeTop();
				if(arrPP.length!=0) topPP=arrPP[arrPP.length-1].pp;
			}
		}
		override public function remove(base:Base=null, index:Number=-1):void{
			for(var i:Number=0;i<arrPP.length;i++){
				if(arrPP[i].b==base){
					var ppp:SpringPopup=arrPP[i].pp as SpringPopup;
					ppp.ReverseStart();
					super.remove(base,index);
					return;
					break;
				}
			}
			//throw new Error("#没有找到弹出效果!");
		}
	}
}